import cook from "./cook.js"

var message = {
    beginGames(){        
        let nullCooker = document.getElementById("nullCooker");
        nullCooker.onclick = cook.employCook;
        //添加雇佣厨师功能
        let beginGames = document.querySelector(".beginGames");
        let beginGamesBtn = document.querySelector(".beginGamesBtn");
        let blackBackground = document.querySelector(".blackBackground");

        setTimeout(() => {
            beginGames.style.visibility = "visible";
            blackBackground.style.background = "rgba(0, 0, 0, 0.4)";
            blackBackground.style.zIndex = "99";
        }, 4000);
        
        beginGamesBtn.addEventListener("click", () => {
            beginGames.style.visibility = "hidden";
            blackBackground.style.background = "";
            blackBackground.style.zIndex = "-99";
        })
    },
    cleanRestaurant(){
        let cook = document.getElementsByClassName("cooker");
        for(let i = 0;i<cook.length;i++){

            if(cook[i].dataset.state !== "null"){
                cook[i].dataset.state = "ready";
                cook[i].children[1].innerHTML = ""
                cook[i].children[2].src = ""
            }
        }

        let customer = document.getElementsByClassName("customers");
        for(let i = 0 ;i<customer.length;i++){
            console.log(customer[i].children)
            customer[i].children[0].src = "./restaurant/noPeople.png";
            customer[i].children[2].innerHTML = "";
            for(let j = 0;j<customer[i].children[1].children.length;j++){
                customer[i].children[1].children[j].dataset.ready = "false";
                customer[i].children[1].children[j].innerHTML = '';
            }
        }
    },tips(text){
        let tips = document.querySelector(".tips");
        let tipsText = document.querySelector(".tipsText");

        tips.style.visibility = "visible"
        tipsText.innerHTML = text;
        setTimeout(() => {
            tips.style.visibility = "hidden"
        }, 3000);
    }
}

export default message;